import { createRouter, createWebHashHistory } from 'vue-router'
import LayoutView from '@/layout/LayoutView'
// component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')

const routes = [
  // 一级路由
  {
    path: '/',
    component: LayoutView,
    // 二级路由
    children: [
      // 首页
      { path: '/', component: () => import('@/views/home/HomeView') },
      // 一级分类
      { path: '/category/:id', component: () => import('@/views/category/CategoryView') },
      // 二级分类
      { path: '/category/sub/:id', component: () => import('@/views/category/sub/SubCategoryView') }
    ]
  },
  // 登录
  {
    path: '/login',
    component: () => import('@/views/login/LoginView')
  }
]

// 创建路由
const router = createRouter({
  // 路由模式为Hash
  history: createWebHashHistory(),
  routes
})

export default router
